package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyTheme;
import cn.wolfcode.wolf2w.query.QueryObject;
import cn.wolfcode.wolf2w.query.StrategyThemeQuery;
import cn.wolfcode.wolf2w.service.IStrategyThemeService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//攻略主体后端控制器
@Controller
@RequestMapping("/strategyTheme")
public class StrategyThemeController {

    @Autowired
    private IStrategyThemeService strategyThemeService;

    /**
     * 高查
     * @param model
     * @param qo
     * @return
     */
    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")StrategyThemeQuery qo) {
        model.addAttribute("page",strategyThemeService.query(qo));
        return "/strategyTheme/list";
    }


    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public JsonResult saveOrUpdate(StrategyTheme strategyTheme) {
        strategyThemeService.saveOrUpdate(strategyTheme);
        return JsonResult.success();
    }

    /**
     * 删除功能
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id) {
        strategyThemeService.delete(id);
        return JsonResult.success();
    }

}
